import request from '@/utils/request';
import { url } from '@/api/url';

// 用户管理-查询表格数据
export async function queryUsers(): Promise<any> {
  return request(url.queryUsersUrl);
}
// 用户管理-查询
export async function searchUser(params: any): Promise<any> {
  return request(url.searchUsersUrl,{params});
}
export async function updateUserProject(data: any): Promise<any> {
  return request(url.updateUserProjectUrl,{
    method:"post",
    data
  });
}
export async function getAllUserByProject(params={}): Promise<any> {
  return request(url.getAllUserByProjectUrl,{params});
}
export async function addUserRole(data: any): Promise<any> {
  return request(url.addUserRoleUrl,{
    method:"post",
    data
  });
}
export async function updateRoleDashboard(data: any): Promise<any> {
  return request(url.updateRoleDashboardUrl,{
    method:"post",
    data
  });
}
export async function deleteRole(roleId: any): Promise<any> {
  return request(url.deleteRoleUrl(roleId),{
    method:"delete",
  });
}

export async function getDashboardList(params: any): Promise<any> {
  return request(url.getDashboardListUrl,{params});
}
export async function deleteRoleUser(data: any): Promise<any> {
  return request(url.deleteRoleUserUrl,{
    method:"post",
    data
  });

}
export async function isExistUser(params: any): Promise<any> {
  return request(url.userIsExistUrl,{params});
}
export async function createUser(data: any): Promise<any> {
  return request(url.createUserUrl,{
    method:"post",
    data
  });
}

export async function getUserPri(): Promise<any> {
  return request(url.userPriUrl);
}
export async function editUserPri(id: any): Promise<any> {
  return request(url.editUserPri(id));
}

// 用户管理-分配身份-身份列表
export async function queryList(): Promise<any> {
  return request(url.queryIdentitysUrl);
}

// 用户管理-分配身份-保存
export async function postIdentity(params: any) {
  return request(url.changeUserIdentity, {
    method: 'POST',
    data: params,
  });
}

// 用户管理-权限管理-分配角色列表
export async function queryRoleList(): Promise<any> {
  return request(url.queryRolesUrl);
}

// 用户管理-权限管理-项目权限列表
export async function queryProjectList(): Promise<any> {
  return request(url.queryProjectsUrl);
}

// 用户管理-权限管理-分配角色-保存
export async function postRole(params: any) {
  return request(url.changeUserRole, {
    method: 'POST',
    data: params,
  });
}

// 用户管理-权限管理-项目权限-保存
export async function postProject(params: any) {
  return request(url.changeUserDashboard, {
    method: 'POST',
    data: params,
  });
}

// 角色管理-创建角色
export async function create(params: any) {
  return request(url.createRoleUrl, {
    method: 'POST',
    data: params,
  });
}

// 角色管理-权限管理-项目列表
export async function queryAllProject(): Promise<any> {
  return request(url.queryDashboardPortalProjectsList);
}

// 角色管理-权限管理-看板列表
export async function queryAllPorta(): Promise<any> {
  return request(url.queryPortalList);
}

// 角色管理-权限管理-保存
export async function postPorta(params: any) {
  return request(url.changeRoleDashboard, {
    method: 'POST',
    data: params,
  });
}

// 数据管理-查询表格数据
export async function queryRoleDataList(): Promise<any> {
  return request(url.queryRoleListUrl);
}

// 数据管理-存储导入数据
export async function createRole(params: any) {
  return request(url.createRole, {
    method: 'POST',
    data: params,
  });
}

export async function queryDataRoleDetail(params: any): Promise<any> {
  return request(url.queryRoleDetailUrl(params));
}

export async function queryRoleAllList(): Promise<any> {
  return request(url.queryRoleAllUrl);
}

export async function bindDataRole(params: any) {
  return request(url.bindDataRole, {
    method: 'POST',
    data: params,
  });
}

export async function queryUserRole(params: any): Promise<any> {
  return request(url.queryUserRoleUrl(params));
}
